package com.hotel.controller;

import com.hotel.domain.Food;
import com.hotel.domain.VipUser;
import com.hotel.service.FoodService;
import com.hotel.service.VipUserService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * ClassName: VipUserController
 *
 * @author 落叶剂的秋
 * Description:
 * date: 2020/12/8 22:27
 */
@RestController
@RequestMapping("/admin")

public class VipUserController {

    @Autowired
    VipUserService vipUserService;

    @ResponseBody
    @GetMapping("/selectAllVipUser")
    public List<VipUser> selectAllVipUser(){
        List<VipUser> vipUsers = vipUserService.selectAllVipUser();
        return vipUsers;
    }


    @GetMapping("/selectByVipid")
    public VipUser selectByVid(int vipid){
        VipUser vipUser = vipUserService.selectByVid(vipid);
        return vipUser;
    }


    @PostMapping("/addVipUser")
    public String addVipUser(VipUser vipUser) {
        int result =vipUserService.addVipUser(vipUser);
        return result>0?"添加成功":"添加失败";
    }

    @PostMapping("/modifyVipUser")
    public String modifyVipUser(int vipid){
        VipUser vipUser=new VipUser();
        vipUser = vipUserService.selectByVid(vipid);
        vipUser.setPhone(123456);
        vipUser.setRank("高级会员");
        vipUser.setVipname("大红花");
        vipUser.setIntegral(100);
        vipUser.setBalance(100);

        int result= vipUserService.modifyVipUser(vipUser);
        return result>0?"修改成功":"添加失败";

    }




}
